package com.heima.wemedia.controller.v1;

import com.baomidou.mybatisplus.extension.api.R;
import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description TODO
 * @Author bo.li
 * @Date 2023/3/16 10:49
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {

    @Autowired
    private WmChannelService wmChannelService;

    @GetMapping("/channels")
    public ResponseResult listAll(){
       return wmChannelService.findAll();
    }
    @PostMapping("/list")
    ResponseResult channelPage(@RequestBody ChannelDto dto){
        return wmChannelService.getChannelPage(dto);
    }

    @GetMapping("/del/{id}")
    ResponseResult deleteChannel(@PathVariable Integer id){
        return wmChannelService.deleteChannel(id);
    }

    @PostMapping("/save")
    ResponseResult channelSave(@RequestBody WmChannel wmChannel){
       return wmChannelService.channelSave(wmChannel);
    }

    @PostMapping("/update")
    ResponseResult channelUpdate(@RequestBody WmChannel wmChannel){
        return wmChannelService.channelUpdate(wmChannel);
    }
}